package com.cosmoplat.xikai.business.service;

import com.cosmoplat.xikai.business.domain.BaseAlarmRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import com.cosmoplat.xikai.business.domain.BaseDeliveryInfo;
import com.cosmoplat.xikai.business.domain.BaseDispatchTask;
import com.cosmoplat.xikai.business.domain.dto.alarm.AlarmQueryDTO;
import com.cosmoplat.xikai.business.domain.dto.scada.DeviceFaultDto;
import com.cosmoplat.xikai.business.domain.mes.req.MesLineAlarmRequest;
import com.cosmoplat.xikai.business.domain.vo.AlarmVo;
import com.cosmoplat.xikai.common.enums.business.AlarmTypeEnum;

import java.util.HashMap;
import java.util.List;

/**
* @author 22047582
* @description 针对表【base_alarm_record】的数据库操作Service
* @createDate 2025-01-07 13:51:29
*/
public interface BaseAlarmRecordService extends IService<BaseAlarmRecord> {

    /**
     *  分页查询
     * @date 14:36 2025/1/13
     * @param deviceFaultDto
     * @return java.util.List<com.cosmoplat.xikai.business.domain.BaseAlarmRecord>
     **/
    List<BaseAlarmRecord> queryForPage(AlarmQueryDTO deviceFaultDto);


    /**
     * 创建告警信息
     * @date 14:15 2025/1/13
     * @param alarmVo
     * @return com.cosmoplat.xikai.business.domain.vo.AlarmVo
     **/
    AlarmVo createAlarmVo(AlarmVo alarmVo);

    /**
     * 通知mes 缺料告警
     * @date 10:49 2025/1/15
     * @param doingTask
     * @param deliveryInfo
     * @param alarmRecord
     **/
    void shortMaterialCallMes(BaseDispatchTask doingTask, BaseDeliveryInfo deliveryInfo, AlarmVo alarmRecord);

    /**
     * 通知mes 质量告警
     *
     * @param doingTask    当前正在进行的任务
     * @param materialCode 物料编码
     * @param alarmContent 告警内容
     * @param productId 产品信息编码
     * @date 11:12 2025/1/15
     **/
    void qualityExceptionCallMes(BaseDispatchTask doingTask, String materialCode, String alarmContent, String productId);

    /**
     * 通知mes  物料错误告警
     * @date 11:08 2025/1/15
     * @param doingTask
     * @param materialCode
     * @param alarmContent
     **/
    void materialErrorCallMes(BaseDispatchTask doingTask, String materialCode, String alarmContent);

    /**
     * 通知mes告警
     * @date 11:08 2025/1/15
     * @param doingTask
     * @param deliveryInfo
     * @param alarmRecord
     * @param enumType
     **/
    void callMesAlarm(BaseDispatchTask doingTask, BaseDeliveryInfo deliveryInfo, AlarmVo alarmRecord, MesLineAlarmRequest.MesExceptionType enumType);

    /**
     * 关闭告警
     *
     * @param doingTask
     * @param materialCode
     * @param alarmTypeEnum
     * @param businessInfo  业务信息（eg:产品编码）
     * @date 11:27 2025/1/15
     **/
    void stopAlarm(BaseDispatchTask doingTask, String materialCode, AlarmTypeEnum alarmTypeEnum, String businessInfo);


    /**
     * 获取告警中的记录
     *
     * @param materialCode
     * @param alarmTypeEnum
     * @return
     */
    List<BaseAlarmRecord> getAlarmingByMaterialCode(String materialCode, AlarmTypeEnum alarmTypeEnum);

    HashMap<String, Long> alarmStatistics(DeviceFaultDto deviceFaultDto);
}
